﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class cn_feedback2 : System.Web.UI.Page
{
    protected string _cid = "43";
    protected void Page_Load(object sender, EventArgs e)
    {
        _cid = Request.QueryString["cid"];
        if (string.IsNullOrEmpty(_cid))
        {
            _cid = ColumnHelp.GetFirstColumnId(16);
        }
        else
        {
            if (!Whir.Common.WebHelper.Utils.IsInt(_cid))
                _cid = ColumnHelp.GetFirstColumnId(16);
        }
        if (!IsPostBack)
        {
            //GetList();
            GetTipsInfo();
        }
    }

    //private void GetList()
    //{
    //    AspNetPager1.PageSize = 18;
    //    string where = "TypeID=" + _cid;
    //    string countSql = "SELECT COUNT(*) FROM Whir_U_Message WHERE " + where;
    //    AspNetPager1.RecordCount = int.Parse(Whir.SQLServerDAL.DbHelperSQL.GetSingle(countSql).ToString());
    //    DataTable dt = Whir.SQLServerDAL.DbHelperSQL.GetList("Whir_U_Message", "Whir_U_Message_PID", "*", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex - 1, where, "", "CreateDate desc").Tables[0];
    //    rptList.DataSource = dt;
    //    rptList.DataBind();

    //}
    //protected void AspNetPager1_PageChanged1(object sender, EventArgs e)
    //{
    //    GetList();
    //}
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string sql = "insert into Whir_U_Message (TypeID,CreateDate,Person,Tel,CompanyName,Address,Content,BM,Mobie) values (@TypeID,@CreateDate,@Person,@Tel,@CompanyName,@Address,@Content,@BM,@Mobie)";

       
        SqlParameter[] pa =
        {
            new SqlParameter("@TypeID",_cid),
            new SqlParameter("@CreateDate",DateTime.Now),
            new SqlParameter("@Person",txtName.Value),
            new SqlParameter("@Tel",txtTel.Value),
            new SqlParameter("@CompanyName",txtCompanyName.Value),
            new SqlParameter("@Address",txtAddress.Value),  
            new SqlParameter("@Content",txtContent.Value),
            new SqlParameter("@BM",txtBM.Value),  
            new SqlParameter("@Mobie",txtMobiel.Value)
        };
        int count = Whir.SQLServerDAL.DbHelperSQL.ExecuteSql(sql, pa);
        if (count > 0)
        {

            Whir.Common.WebHelper.JsHelper.redirect(this.Page, "发送成功!", "feedback2.aspx?cid=" + _cid);


        }
        else { Whir.Common.WebHelper.JsHelper.Alert(this.Page, "发送失败!"); }
    }

    protected string GetReplayTime(string dateTime)
    {
        if (!string.IsNullOrEmpty(dateTime))
        {
            return string.Format("({0})", Convert.ToDateTime(dateTime).ToString("yyyy-MM-dd"));
        }

        return "";
    }
    private void GetTipsInfo()
    {
        ltrTips.Text = ColumnHelp.GetColumnName(_cid);
    }
}
